var PicUrl='';

if (SysStyle==1)
{
	PicUrl='';
}
else{
	PicUrl=SystemFolder;
}

var TempStr=document.getElementById('xmlArticleList').selectSingleNode("//Content").text;
var TopicList=TempStr.split("{{}}");

function ShowList(StyleId){
	var TempStr,Tmp;

	/*TempStr='<table>';*/
	TempStr='';
	switch (StyleId)
	{
	case 0:
		for (i=0;i<=RCount;i++){
			Tmp=TopicList[i].split("|");

			TempStr+='<li>';
			TempStr+=CheckTitleTypes(Tmp[8],Tmp[10]);
			TempStr+='<a href="'+Tmp[11]+'" rel="external">'+TitleAddColor(Tmp[2],Tmp[1])+'</a>';
			TempStr+='&nbsp;<span class=""link-Date"">发布日期:'+Tmp[3];
			TempStr+='&nbsp;浏览次数:'+Tmp[7]+'</span>';
			//TempStr+='&nbsp;Review:'+Tmp[4]+'</span></td>';
			TempStr+='</li>';
		}
		break;

	case 1:
		for (i=0;i<=RCount;i++){
			Tmp=TopicList[i].split("|");

			TempStr+='<tr>';
			TempStr+='<td style="width: 65%;">&nbsp;'+CheckTitleTypes(Tmp[8],Tmp[10]);
			TempStr+='<a href="'+Tmp[11]+'" rel="external">'+TitleAddColor(Tmp[2],Tmp[1])+'</a></td>';
			TempStr+='<td>'+Tmp[3]+'</td>';
			TempStr+='<td>Browse:'+Tmp[7]+'</td>';
			TempStr+='</tr>';
			TempStr+='<tr style="height: 50px;">';
			TempStr+='<td colspan="3">'+cleanHtml(Tmp[5])+'</td>';
			TempStr+='</tr>';
			TempStr+='<tr>';
			TempStr+='<td colspan="2">最新评论:';
			if (Tmp[6]=="")
			{
				TempStr+='暂无评论';
			}
			else{
				TempStr+=Tmp[6];
			}
			TempStr+='</td>';
			TempStr+='<td>Review:'+Tmp[4]+'</td>';
			TempStr+='</tr>';
		}
		break;

	case 2:
		var j=0;
		for (i=0;i<=RCount;i++){
			Tmp=TopicList[i].split("|");
			
			if ((j % 3)==0)
			{
				TempStr+='<tr>';
			}

			TempStr+='<td style="width: 33%;height: 100px;TEXT-ALIGN: center;">&nbsp;<a href="'+Tmp[11]+'" rel="external">';
			if (Tmp[9]=="")
			{
				TempStr+='<img src="'+PicUrl+'images/public/no_picture.gif" alt="'+Tmp[2]+'" style="width: 90px;" />';
			}
			else{
				TempStr+='<img src="'+Tmp[9]+'" style="width: 90px;" alt="'+Tmp[2]+'" />';
			}

			TempStr+='<br>'+CheckTitleTypes(Tmp[8],Tmp[10]);
			TempStr+='<a href="'+Tmp[11]+'" rel="external">'+TitleAddColor(Tmp[2],Tmp[1])+'</a></td>';

			if (j==2)
			{
				TempStr+='</tr><tr>';
				j=0;
			}
			else{
				j+=1;
			}
		}
		break;

	case 3:
		for (i=0;i<=RCount;i++ )
		{
			Tmp=TopicList[i].split("|");

			TempStr+='<tr>';
			TempStr+='<td style="width: 25%px;height: 100px;">&nbsp;<a href="'+Tmp[11]+'" rel="external">';
			if (Tmp[9]=="")
			{
				TempStr+='<img src="'+PicUrl+'images/public/no_picture.gif" alt="'+Tmp[2]+'" style="width: 90px;" />';
			}
			else{
				TempStr+='<img src="'+Tmp[9]+'" style="width: 90px;" alt="'+Tmp[2]+'" />';
			}
			TempStr+='</td>';
			TempStr+='<td>';
			TempStr+='<table>';
			TempStr+='<tr>';
			TempStr+='<td>&nbsp;'+CheckTitleTypes(Tmp[8],Tmp[10]);
			TempStr+='<a href="'+Tmp[11]+'" rel="external">'+TitleAddColor(Tmp[2],Tmp[1])+'</a></td>';
			TempStr+='</tr>';
			TempStr+='<tr style="height: 50px;">';
			TempStr+='<td>'+cleanHtml(Tmp[5])+'</td>';
			TempStr+='</tr>';
			TempStr+='<tr>';
			TempStr+='<td>浏览:'+Tmp[7]+'&nbsp;评论:'+Tmp[4]+'&nbsp;发表时间:'+Tmp[3]+'</td>';
			TempStr+='</tr>';
			TempStr+='</table>';
			TempStr+='</td>';
			TempStr+='</tr>';
		}
		break;
	}

	/*TempStr+='</table>';*/

	document.getElementById('CommentList').innerHTML=TempStr;

	if (document.location.href.indexOf("#") > 0)
	{
		document.location.href = document.location.href.substring(0,document.location.href.indexOf("#")) + "#";
	}
	else{
		document.location.href+="#";
	}
}

function CheckTitleTypes(vIsImg,vIsTop){
	if (vIsImg=="True")
	{
		return '<img src="'+PicUrl+'images/public/article_img.gif" alt="图片文章" />&nbsp;';
	}
	else{
		if (vIsTop=="True")
		{
			return '<img src="'+PicUrl+'images/public/article_top.gif" alt="推荐文章" />&nbsp;';
		}
		else{
			return '<img src="'+PicUrl+'images/public/article_normal.gif" alt="普通文章" />&nbsp;';
		}
	}
}

function TitleAddColor(vTitle,vTColor){
	switch (vTColor)
	{
	case "1":
		return '<font color="#FF0000">'+vTitle+'</font>';
	case "2":
		return '<font color="#37a61c">'+vTitle+'</font>';
	case "3":
		return '<font color="#0066CC">'+vTitle+'</font>';
	default :
		return vTitle;
	}
}

function cleanHtml(ReContents)
{
	ReContents = ReContents.replace(/<p>&nbsp;<\/p>/gi,"")
	ReContents = ReContents.replace(/<p><\/p>/gi,"<br>")
	ReContents = ReContents.replace(/<p>/,"<br>")
	ReContents = ReContents.replace(/<\/p>/,"<br>")
	ReContents = ReContents.replace(/<li>/,"<br>")
	ReContents = ReContents.replace(/<lu>/,"<br>")
	ReContents = ReContents.replace(/(<(meta|iframe|frame|span|tbody|layer)[^>]*>|<\/(iframe|frame|meta|span|tbody|layer)>)/gi, "");
	ReContents = ReContents.replace(/<\\?\?xml[^>]*>/gi, "") ;
	ReContents = ReContents.replace(/o:/gi, "");
	ReContents = ReContents.replace(/&nbsp;/gi, " ");
	ReContents = ReContents.replace(/(<(style|strong)[^>]*>|<\/(style|strong)>)/gi, "");
	ReContents = ReContents.replace(/^\[ \t]*$/,"")
	ReContents = ReContents.replace(/(<(table|tbody|tr|td|th|)[^>]*>|<\/(table|tbody|tr|td|th|)>)/gi, "");
	ReContents = ReContents.replace(/(<(img)[^>]*>|<\/(img)>)/gi, "");
	ReContents = ReContents.replace(/(<(div|blockquote|fieldset|legend)[^>]*>|<\/(div|blockquote|fieldset|legend)>)/gi, "");
	ReContents = ReContents.replace(/(<(font|i|u|h[1-9]|s)[^>]*>|<\/(font|i|u|h[1-9]|s)>)/gi, "");
	ReContents = ReContents.replace(/(<script[^>]*>|<\/script>)/gi, "");

	RegExp = /<(\w[^>|\s]*)([^>]*)(on(finish|mouse|Exit|error|click|key|load|change|focus|blur))(.[^>]*)/gi;
	ReContents = ReContents.replace(RegExp, "<$1")

	RegExp = /<(\w[^>|\s]*)([^>]*)(&#|window\.|id|javascript:|js:|about:|file:|Document\.|vbs:|cookie| name| id)(.[^>]*)/gi;
	ReContents = ReContents.replace(RegExp, "<$1")
	
	return ReContents;
}
